﻿using System;
using System.Text.Json.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;


namespace Shared.Service.Authorizations.Authorization.HttpApis
{
    public class HttpApiResult
    {
        /// <summary>
        /// 
        /// </summary>
        [JsonPropertyName("result")]
        [JsonProperty("result")]
        public string MsgCode { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [JsonPropertyName("msg")]
        [JsonProperty("msg")]
        public string Msg { get; set; }

        [Newtonsoft.Json.JsonIgnore]
        public bool Success =>  "000000".Equals(MsgCode) || "0000".Equals(MsgCode);

        /// <summary>
        /// 
        /// </summary>
        [JsonPropertyName("data")]
        [JsonProperty("data")]
        public JToken Data { get; set; }
    }


    public class GetUserDataScopesRequest
    {
        public GetUserDataScopesRequest(string userId, string policyName)
        {
            //var m = DateTime.Now.Microsecond;
            //var generator = new IdGenerator(m);
            //this.Id = generator.CreateId();
            //Console.WriteLine($"---{Id}--||||{m}|||----");
            // BrandId = brandId;
            UserId = userId;
            PolicyName = policyName;
        }
        /// <summary>
        /// 
        /// </summary>
        [JsonPropertyName("menuCode")]
        [JsonProperty("menuCode")]
        public string PolicyName { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [JsonPropertyName("brandId")]
        [JsonProperty("brandId")]
        public string BrandId { get; set; }

        [JsonPropertyName("userId")]
        [JsonProperty("userId")]
        public string UserId { get; set; }
    }


    public class GetIsGrantedRequest
    {

        public GetIsGrantedRequest(string brandId, string userId,string policyName)
        {
            BrandId = brandId;
            UserId = userId;
            PolicyName = policyName;
        }

        /// <summary>
        /// 
        /// </summary>
        [JsonPropertyName("brandId")]
        [JsonProperty("brandId")]
        public string BrandId { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [JsonPropertyName("userId")]
        [JsonProperty("userId")]
        public string UserId { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [JsonPropertyName("menuCode")]
        [JsonProperty("menuCode")]
        public string PolicyName { get; set; }
    }

    public class PermissionGrantResult
    {
        [JsonPropertyName("IsGranted")]
        [JsonProperty("IsGranted")]
        public bool IsGranted { get; set; }
    }
}
